package com.longjianghuasheng.logistics.business.mine.fragment

import android.os.Bundle
import com.longjianghuasheng.logistics.R
import com.longjianghuasheng.logistics.base.BaseTitleFragment
import com.longjianghuasheng.logistics.business.mine.AboutViewModel
import com.longjianghuasheng.logistics.databinding.FragmentAboutBinding
import com.longjianghuasheng.logistics.ext.loadRichText
import com.longjianghuasheng.logistics.ext.observer
import me.hgj.jetpackmvvm.ext.view.visible


class AboutFragment : BaseTitleFragment<AboutViewModel, FragmentAboutBinding>() {

    override fun layoutId(): Int = R.layout.fragment_about

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
    }

    override fun createObserver() {
        super.createObserver()
        mViewModel.result.observer(this) {
            initTitleBar(it.title ?: "")


            mDatabind.run {


                tvContent.loadRichText(it.content ?: "", !(it.content?.contains("<img") ?: false))
                clBg.visible()
            }
        }

    }

    override fun initData() {
        super.initData()
        arguments?.run {
            mViewModel.id = getInt("id")
            mViewModel.isProblem = getBoolean("isProblem")

        }
    }

    override fun lazyLoadData() {
        super.lazyLoadData()
        mViewModel.abouts()
    }


}